
import { Button, Tabs } from 'antd'
import { WeaErrorPage, WeaTools } from 'ecCom'
import {
    WeaTop,
    WeaTab,
    WeaLeftRightLayout,
} from 'ecCom'
import LeftTab from './LeftTab';
import AttentionWeiboList from './AttentionWeiboList';
import * as AttCon from '../../constants/AttentionConstant';
import HisWeiboContainer from './HisWeiboContainer';
import {routerShape} from 'react-router';
import WeaBlogDict from '../Component/wea-blog-dict';
import '../../style/myAttention.less';
const TabPane = Tabs.TabPane;
const innerHref = WeaBlogDict.href;
import {inject, observer} from 'mobx-react';
import {observable,action,toJS} from 'mobx';
@inject('blogMyAttention')
@observer
class MyAttention extends React.Component {
  static contextTypes = {
    router: routerShape
  };
	constructor(props) {
		super(props);
	}
	componentDidMount() {
			// 保证刷新时进入列表，而不是人员页。
			let {status} = this.props.blogMyAttention;
			let {rightType} = toJS(status);
			if (rightType == AttCon.RIGHT_TYPE_WEIBO && this.props.params && this.props.params.userId) {
      let {router} = this.context;
      if(router) {
        router.push(innerHref.viewAttentionList());
      }
    }
	    //一些初始化请求
		this.props.blogMyAttention.getCurrentUser();
	}
    componentWillUnmount() {
        this.props.blogMyAttention.resetRight();
    }
	render() {
		let {status} = this.props.blogMyAttention;
		let {loading, title} = toJS(status);
		return (
			<div className='wea-blog-my-attention'>
				<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@d9lro0`}
	              	title={title}
	              	loading={loading}
	              	icon={<span className='icon-coms-blog'/>}
                    iconBgcolor='#6d3cf7'
	              	buttons={[]}
	              	>
					<WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@v5y9xh`} isNew={true} showLeft={true} leftCom={<LeftTab ecId={`${this && this.props && this.props.ecId || ''}_LeftTab@zfsfwx`}/>} leftFixed={true}>
						<div className="wea-right-container">
                            {this.props.children}
						</div>
	              	</WeaLeftRightLayout>
              	</WeaTop>
            </div>
		)
	}

}

//组件检错机制
class MyErrorHandler extends React.Component {
	render() {
		const hasErrorMsg = this.props.error && this.props.error !== "";
		return(
			<WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@tddnn4`} msg={ hasErrorMsg ? this.props.error : "对不起，该页面异常，请联系管理员！" } />
		);
	}
}

MyAttention = WeaTools.tryCatch( React, MyErrorHandler, { error: "" })(MyAttention);

export default MyAttention;